#include "stcmd14_struct.h"
#include "stm8l15x_it.h"
#include "PublicSet1.h"
#include "LHead.h"
#include "extern1.h"
#include "IOSet1.h"
#include "picpredef.h"
#include "prog_record_unit.h"
#include "changekey.h"

u32	serv_04000106_07(u32 Code)
{ 
 struct  stCMD14_STRUCT * p 	=		(( struct  stCMD14_STRUCT *)ComData );
	u32	Cnt = 0 ;
	u8 x  ; 
	u8	TmBCD[6];
	
	extern const u8 Const699[] ;
	extern const u8 zeroP[];
	
	Code = Code - 0x106;
	
	x=1 ;
	if ( strCmp ((p->unWriteData).sWriteData  ,Const699, 5 ) == 0 )
			x = 0;
			
	if(Code < 4)
	{
						if ( x )
						{
									Cnt = GetMvData(READ_RAM(vComData+6, READ_BCD_TIME(TP_MIN, TP_SEC)));
								
										GetCntTime(TmBCD, Cnt);
										if(strCmp(TmBCD+1, (p->unWriteData).sWriteData, 5)!=0)
										{
											SetErrReturn(1);
											return SUCCESS;
										}
					}else{
						Cnt=0x99999999;
					}
									
					Copy_FlashInfo( ((u8*)(&FlashInfo.SafeInfo.StartTm_1))+Code*4, (u8*)&Cnt, 4);
					AddProgRecord(*(u32*)(ComData+2));
					RamData.State.Event_Feilv = 1;
	}
	ComData[1] = 0;
	return SUCCESS;
}
